//
//  FindViewController.m
//  WidgetDemo
//
//  Created by 航汇聚科技 on 2018/4/13.
//  Copyright © 2018年 Yi Zhou. All rights reserved.
//

#import "FindViewController.h"

#import "ProgressView.h"

#import "XLCircleProgress.h"

@interface FindViewController ()

@end

@implementation FindViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

static float value = 0.00;
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    
    value += 0.05;
    
    if (value > 1) {
        value = 0.00;
    }
    
    CGFloat margin = 100.0f;
    CGFloat circleWidth = [UIScreen mainScreen].bounds.size.width - 2*margin;
    XLCircleProgress *circle = [[XLCircleProgress alloc] initWithFrame:CGRectMake(0, 0, circleWidth, circleWidth)];
    circle.center = self.view.center;
    [self.view addSubview:circle];
    
    if (@available(iOS 10.0, *)) {
        NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1 repeats:YES
                                                           block:^(NSTimer * _Nonnull timer) {
                                                               value += 0.05;
                                                               
                                                               if (value > 1) {
                                                                   value = 0.00;
                                                               }
                                                               circle.progress = value;
                                                           }];
        
        [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
        
    } else {
        // Fallback on earlier versions
    }
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
